#include "timer0.h"
void time0_init()
{
    // 工作方式1,16位,计时模式
    TMOD |= 0X01;
}

void time0_init1()
{
    // 工作方式1,16位,计数器模式
    TMOD |= 0X05;
}

void time0_set_counterstart(unsigned int begain_data){
    TH0=begain_data/256;
    TL0=begain_data%256;
}

unsigned int time0_get_counter(){
    unsigned int counter=(TH0<<8)|TL0;
    return counter;
}

void time0_start(unsigned char inflag)
{
    if (inflag)
    {
        // 定时器0中断打开
        ET0 = 1; // 打开定时器0中断
        EA = 1;  // 打开总中断
    }
    // 开始运行
    TR0 = 1;
}